package xiaomin.demo.algorithm;

public class Lesson23 {
    public static void run(){
        int[] arr={1,3,5,6,7,13,14,19};
        int x=15;
        int index=-1;
        int start=0,end=arr.length-1;

        while (start!=end){
            index =start+(end-start)/2;
            if(arr[index]==x){
                System.out.println(index);
                break;
            }
            else if(arr[index]>x){
                end=index-1;
            }
            else {
                start=index+1;
            }
        }
        if(arr[start]==x){
            System.out.println(start);
        }
        else
            System.out.println("没找到,插入位置"+start);
    }
}
